class UserInformation {
  String username;
  int id;
  String avatarPic;
  String themeColor;

  UserInformation({
    this.avatarPic,
    this.id,
    this.themeColor,
    this.username,
  });

  factory UserInformation.fromJson(Map<String, dynamic> json) {
    print('fromJOSN $json   ${json['id'].runtimeType}');
    String name = json['name'];
    int userId;
    if (json['name'] == null) {
      name = json['url_name'];
    }
    if (json['id'].runtimeType == int) {
      userId = json['id'];
    } else {
      userId = int.parse(json['id']);
    }
    return UserInformation(
        avatarPic: json['avatar_pic'],
        id: userId,
        username: name,
        themeColor: json['theme_color']);
  }
}

// 用户基本信息
class UserAppInfo {
  final int state;
  final String name;
  final String nickName;
  final String phoneNum;
  final String logoUrl;

  UserAppInfo({this.state, this.name, this.nickName, this.phoneNum, this.logoUrl});
  factory UserAppInfo.fromJson(Map<String, dynamic> json) {
    return UserAppInfo(
        state: json['state'] as int,
        name: json['name']  == null ? '---': json['name'] as String,
        nickName: json['nickName'] == null ? '---': json['nickName'] as String,
        phoneNum: json['phoneNum'] == null ? '---': json['phoneNum'] as String,
        logoUrl: json['logoUrl'] as String,
    );
  }
}